package com.base.data.elasticsearch.core.operation;

import com.base.data.elasticsearch.core.BaseSearchResultMapper;
import com.base.data.elasticsearch.core.query.BaseCriteriaQuery;
import com.base.data.elasticsearch.core.query.BaseSearchQuery;
import org.springframework.data.domain.Page;
import org.springframework.lang.Nullable;

import java.util.List;

public interface BaseElasticsearchOperationScroll extends BaseElasticsearchOperation{

    /**
     * Returns scrolled page for given query
     *
     * @param query The search query.
     * @param scrollTimeInMillis The time in millisecond for scroll feature
     * {@link org.elasticsearch.action.search.SearchRequestBuilder#setScroll(org.elasticsearch.common.unit.TimeValue)}.
     * @param clazz The class of entity to retrieve.
     * @return The scan id for input query.
     */
    //done
    <T> Page<T> startScroll(long scrollTimeInMillis, BaseSearchQuery query, Class<T> clazz);

    /**
     * Returns scrolled page for given query
     *
     * @param query The search query.
     * @param scrollTimeInMillis The time in millisecond for scroll feature
     * {@link org.elasticsearch.action.search.SearchRequestBuilder#setScroll(org.elasticsearch.common.unit.TimeValue)}.
     * @param mapper Custom impl to map result to entities
     * @return The scan id for input query.
     */
    //done
    <T> Page<T> startScroll(long scrollTimeInMillis, BaseSearchQuery query, Class<T> clazz, BaseSearchResultMapper mapper);

    /**
     * Returns scrolled page for given query
     *
     * @param criteriaQuery The search query.
     * @param scrollTimeInMillis The time in millisecond for scroll feature
     * {@link org.elasticsearch.action.search.SearchRequestBuilder#setScroll(org.elasticsearch.common.unit.TimeValue)}.
     * @param clazz The class of entity to retrieve.
     * @return The scan id for input query.
     */
    //to test
    <T> Page<T> startScroll(long scrollTimeInMillis, BaseCriteriaQuery criteriaQuery, Class<T> clazz);


    //done
    <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz);
    //done
    <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, BaseSearchResultMapper mapper);
    /**
     * Clears the search contexts associated with specified scroll ids.
     *
     * @param scrollId
     *
     */
    //done
    <T> void clearScroll(String scrollId);
    //done
    void clearScroll(List<String> scrollId);

}
